#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 3e5+10;

int cnt,p[N],dep[N],fa[22][N],diam,n;
vector<int> s1,s2;

void addnode(int x,int p){
	fa[0][x] = p; dep[x] = dep[p]+1;
	for(int i = 1;i < 22;i++) fa[i][x] = fa[i-1][fa[i-1][x]];
}

int lca(int x,int y){//cout<<x<<" "<<y<<endl;
	if(dep[x] < dep[y]) swap(x,y);
	for(int i = 21;~i;i--) if(dep[fa[i][x]] >= dep[y]) x = fa[i][x];
	if(x == y) return x;
	for(int i = 21;~i;i--) if(fa[i][x] != fa[i][y]) x = fa[i][x],y = fa[i][y];
//	cout<<fa[0][x]<<endl;
	return fa[0][x];
}

int dis(int x,int y){return dep[x] + dep[y] - 2 * dep[lca(x,y)];}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in+1; s1.pb(1);
	addnode(1,0); for(int i = 2;i <= n;i++) p[i] = in; 
	for(int i = 2;i <= n;i++){
		addnode(i,p[i]);
		int d1 = s1.size() ? dis(s1[0],i) : 0;
		int d2 = s2.size() ? dis(s2[0],i) : 0;
		if(max(d1,d2) > diam){
			diam = max(d1,d2);
			if(d1 == diam){
				for(int x : s2) if(dis(x,i) == diam) s1.pb(x);
				s2.clear();
			}else{
				for(int x : s1) if(dis(x,i) == diam) s2.pb(x);
				s1.clear();
			}
		}
		if(d1 == diam) s2.pb(i);else if(d2 == diam) s1.pb(i);
		printf("%lu\n",s1.size()+s2.size());
	}
	return 0;
}

